package com.itheima.service.impl;

import com.itheima.dao.WebConfigMapper;
import com.itheima.entity.Result;
import com.itheima.pojo.WebConfig;
import com.itheima.service.WebConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Description:
 *
 * @author WangChang
 * @date 2020/8/5 10:05
 */
@Service
public class WebConfigServiceImpl implements WebConfigService {
    @Autowired
    private WebConfigMapper webConfigMapper;

    @Override
    public Result editWebConfig(WebConfig webConfig) {
        try {
            int i = webConfigMapper.updateByPrimaryKey(webConfig);
            if (i==0){
                return new Result(00001+"", "修改失败！");
            }
        }catch (Exception e){
            e.printStackTrace();
            return new Result(00001+"", "修改失败！");
        }

        return new Result(200+"", "修改成功！");
    }

    @Override
    public Result<WebConfig> getWebConfig() {
        WebConfig webConfig = webConfigMapper.selectAll().get(0);
        return new Result("success", webConfig);
    }
}
